﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace schedule
{
    public partial class MainForm : Form
    {
        public static Calendar calendar = new Calendar();
        public MainForm()
        {
            InitializeComponent();
        }

        private void clickHome()
        {
            this.Invoke(new MethodInvoker(
            delegate()
            {
                //Calendar f = new Calendar();
                calendar.TopLevel = false;
                calendar.Parent = this.panel1;
                calendar.Show();
                calendar.setToday();
            }));
        }

        private void btnHome_Click(object sender, EventArgs e)
        {
            clickHome();
        }

        private void MainForm_Load(object sender, EventArgs e)
        {
            // init form to calendar
            clickHome();
        }

        private void btnMake_Click(object sender, EventArgs e)
        {
            WorkManager wm = WorkManager.Instance();
            MakeForm makeForm = new MakeForm(false);
            if (makeForm.ShowDialog() == DialogResult.OK)
            {
                // 수정!
                WorkInfo wi = new WorkInfo();
                wm.changeWorkInfo(wi, makeForm);
                wm.add(wi);
                calendar.refreshScreen();
            }
        }

        private void btn_Test_Click(object sender, EventArgs e)
        {
            Form1 f = new Form1();
            f.Show();
        }

        private void btnSearch_Click(object sender, EventArgs e)
        {
            Category1 categoryForm = new Category1(true);
            categoryForm.ShowDialog();

            calendar.refreshScreen();
        }

        private void btnSetting_Click(object sender, EventArgs e)
        {
            WorkManager wm = WorkManager.Instance();
            Setting setting = new Setting();
            setting.cbAlarm.Checked = wm.ableAlarm;
            if (setting.ShowDialog() == DialogResult.OK)
            {
                wm.ableAlarm = setting.cbAlarm.Checked;
            }
        }
    }
}
